package com.hsnn.medstgmini.pro.plan.model;

import java.sql.Timestamp;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.hsnn.medstgmini.util.DateUtil;

/**
 * @category 调价计划 实体类
 * @author 韩守松
 * @date 2015年6月17日
 */
@Entity
@Table(name = "base_priceadjplan")
public class BasePriceadjplan implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 2254870005591084316L;
	private String priceAdjPlanId;// 调价计划ID
	private String priceAdjPlanName;// 调价计划名称
	private String priceAdjPlanCat;// 调价药品类型
	private Short executeCat;// 执行类型1手动类型2定时类型
	private String executeCatName; // 执行类型名称
	private Timestamp createDatetime;// 创建时间
	private String createDatetimeStr;
	private String createUser;// 创建人
	private Timestamp executeDatetime;// 执行时间
	private String executeDateTimeStr; // 格式化执行时间
	private String priceAdjAccord;// 调价依据
	private String remark;// 备注
	private Short status;// 状态0未执行1已执行
	private Timestamp updDatetime;// 更新时间
	private String updUser;// 更新人

	private String priceAdjPlanCatText;
	private String createOrgId;
	
	@Column(name = "create_org_id", length = 36)
	public String getCreateOrgId() {
		return createOrgId;
	}

	public void setCreateOrgId(String createOrgId) {
		this.createOrgId = createOrgId;
	}

	private BasePriceadjplandetail basePriceadjplandetail;// 调价计划明细对象

	// Constructors

	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@PrimaryKeyJoinColumn
	public BasePriceadjplandetail getBasePriceadjplandetail() {
		return basePriceadjplandetail;
	}

	public void setBasePriceadjplandetail(
			BasePriceadjplandetail basePriceadjplandetail) {
		this.basePriceadjplandetail = basePriceadjplandetail;
	}

	/** default constructor */
	public BasePriceadjplan() {
	}

	/** minimal constructor */
	public BasePriceadjplan(String priceAdjPlanId) {
		this.priceAdjPlanId = priceAdjPlanId;
	}

	/** full constructor */
	public BasePriceadjplan(String priceAdjPlanId, String priceAdjPlanName,
			String priceAdjPlanCat, Short executeCat, Timestamp createDatetime,
			String createUser, Timestamp executeDatetime,
			String priceAdjAccord, String remark, Short status,
			Timestamp updDatetime, String updUser) {
		this.priceAdjPlanId = priceAdjPlanId;
		this.priceAdjPlanName = priceAdjPlanName;
		this.priceAdjPlanCat = priceAdjPlanCat;
		this.executeCat = executeCat;
		this.createDatetime = createDatetime;
		this.createUser = createUser;
		this.executeDatetime = executeDatetime;
		this.priceAdjAccord = priceAdjAccord;
		this.remark = remark;
		this.status = status;
		this.updDatetime = updDatetime;
		this.updUser = updUser;
	}

	// Property accessors
	@Id
	@GeneratedValue(generator = "BasePriceadjplangenerator")
	@GenericGenerator(name = "BasePriceadjplangenerator", strategy = "uuid")
	@Column(name = "price_adj_plan_id", insertable = false, updatable = false, length = 36)
	public String getPriceAdjPlanId() {
		return this.priceAdjPlanId;
	}

	public void setPriceAdjPlanId(String priceAdjPlanId) {
		this.priceAdjPlanId = priceAdjPlanId;
	}

	@Column(name = "price_adj_plan_name", length = 512)
	public String getPriceAdjPlanName() {
		return this.priceAdjPlanName;
	}

	public void setPriceAdjPlanName(String priceAdjPlanName) {
		this.priceAdjPlanName = priceAdjPlanName;
	}

	@Column(name = "price_adj_plan_cat", length = 128)
	public String getPriceAdjPlanCat() {
		return this.priceAdjPlanCat;
	}

	public void setPriceAdjPlanCat(String priceAdjPlanCat) {
		this.priceAdjPlanCat = priceAdjPlanCat;
	}

	@Column(name = "execute_cat")
	public Short getExecuteCat() {
		return this.executeCat;
	}

	public void setExecuteCat(Short executeCat) {
		this.executeCat = executeCat;
	}

	@Column(name = "create_datetime", length = 19)
	public Timestamp getCreateDatetime() {
		return this.createDatetime;
	}

	public void setCreateDatetime(Timestamp createDatetime) {
		this.createDatetime = createDatetime;
	}

	@Column(name = "create_user", length = 36)
	public String getCreateUser() {
		return this.createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	@Column(name = "execute_datetime", length = 19)
	public Timestamp getExecuteDatetime() {
		return this.executeDatetime;
	}

	public void setExecuteDatetime(Timestamp executeDatetime) {
		this.executeDatetime = executeDatetime;
	}

	@Transient
	public String getExecuteDateTimeStr() {
		if (executeDatetime != null) {
			executeDateTimeStr = DateUtil.format(executeDatetime, "yyyy-MM-dd HH:mm:ss");
		}
		return executeDateTimeStr;
	}

	public void setExecuteDateTimeStr(String executeDateTimeStr) {
		this.executeDateTimeStr = executeDateTimeStr;
	}

	@Transient
	public String getCreateDatetimeStr() {
		if (createDatetime != null) {
			createDatetimeStr = DateUtil.format(createDatetime, "yyyy-MM-dd HH:mm:ss");
		}
		return createDatetimeStr;
	}

	public void setCreateDatetimeStr(String createDatetimeStr) {
		this.createDatetimeStr = createDatetimeStr;
	}

	@Column(name = "price_adj_accord", length = 512)
	public String getPriceAdjAccord() {
		return this.priceAdjAccord;
	}

	public void setPriceAdjAccord(String priceAdjAccord) {
		this.priceAdjAccord = priceAdjAccord;
	}

	@Column(name = "remark", length = 1024)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "status")
	public Short getStatus() {
		return this.status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	@Column(name = "upd_datetime", length = 19)
	public Timestamp getUpdDatetime() {
		return this.updDatetime;
	}

	public void setUpdDatetime(Timestamp updDatetime) {
		this.updDatetime = updDatetime;
	}

	@Column(name = "upd_user", length = 36)
	public String getUpdUser() {
		return this.updUser;
	}

	public void setUpdUser(String updUser) {
		this.updUser = updUser;
	}

	@Transient
	public String getPriceAdjPlanCatText() {
		return priceAdjPlanCatText;
	}

	public void setPriceAdjPlanCatText(String priceAdjPlanCatText) {
		this.priceAdjPlanCatText = priceAdjPlanCatText;
	}

	@Transient
	public String getExecuteCatName() {
		executeCatName = ExecuteType.getName(executeCat);
		return executeCatName;
	}

	public void setExecuteCatName(String executeCatName) {
		this.executeCatName = executeCatName;
	}

}